package gstyle;

import com.google.gwt.user.client.ui.Widget;

public class ElementId extends Style<ElementId> implements CssSelector, XPathSelector, CanSetOnWidget {
    public ElementId(String id) {
        super(id);
    }

    String getName() {
        return "#" + name;
    }

    public String toSelector() {
        return getName();
    }

    public String toXPath() {
        return "[@id='" + name + "']";
    }

    public <T extends Widget> T setOn(T widget) {
        widget.getElement().setId(name);
        return widget;
    }
}
